﻿using CapturePackageWebApi.Model;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Text;

namespace CapturePackageWebApi.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class CapturePackageController : ControllerBase
    {
        public CapturePackageController()
        {

        }

        [HttpPost]
        [Route("GetHtmlText")]
        public List<string> GetHtmlText([FromBody] HerderModel herderModel)
        {
            //HttpHelper.DownloadHtmlModel(herderModel, Encoding.UTF8);
            return CommoditySearch.CrawlerList(HttpHelper.DownloadHtmlModel(herderModel, Encoding.UTF8), herderModel.XpathText);
        }

        [HttpPost]
        [Route("GetImageUrl")]
        public string GetImageTitle(TextModel textModel)
        {
            return CommoditySearch.GetImageTitle(textModel);
        }

        [HttpPost]
        [Route("Gethref")]
        public string Gethref(TextModel textModel)
        {
            return CommoditySearch.Gethref(textModel);
        }

        [HttpPost]
        [Route("GetTitle")]
        public string GetImageUrl(TextModel textModel)
        {
            return CommoditySearch.GetImageUrl(textModel);
        }
    }
}
